<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>axios</title>
  <script src="../js/axios.js"></script>
  <script src="../js/qs.js"></script>
  <script>
    let qs = Qs
    // 配置默认baseURL
    axios.defaults.baseURL= 'http://203.195.246.58:5588'
    // 设置响应拦截器
    let interceptor = axios.interceptors.response.use(response => {
      let res = {
        ...response,
        data: response.data.data,
        status: response.data.status,
        message: response.data.message,
        timestamp: response.data.timestamp,
        test: 'hello 拦截器'
      }
      // console.log(response);
      // Do something before response is sent
      // return response;
      return res;
    },error => {
      // Do something with response error
      return Promise.reject(error);
    });
    axios.get('/category/findAll').then(res => {
      console.log(res.data);
    }).catch(err => {
      console.log(err);
    })
    // 移除响应拦截器
    setTimeout(function() {
      axios.interceptors.response.eject(interceptor)
      axios.get('/category/findAll').then(res => {
        console.log(res);
      })
    },3000)
  </script>
</head>
<body>
  
</body>
</html>